package org.zizi.hessian;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class TestServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	
	private VatOutApi api = new VatOutApiImpl();
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
	
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String identify = req.getParameter("id");
		int year = Integer.parseInt(req.getParameter("year"));
		int month = Integer.parseInt(req.getParameter("month"));
		
		try {
			double value = api.getApplyVatCredit(identify, year, month);
			resp.getWriter().write(String.valueOf(value));
		} catch (Exception e) {
			resp.getWriter().write("-1");
		}
	}
}
